const sass = require('sass');
const loadGruntTasks = require('load-grunt-tasks');

module.exports = grunt => {
  grunt.initConfig({
    clean: {
      temp: 'dist'
    },
    babel: {
      options: {
        presets: ['@babel/preset-env'],
      },
      main: {
        files: {
          'dist/js/app.js': 'src/assets/scripts/main.js',
        },
      },
    },
    sass: {
      options: {
        implementation: sass,
      },
      main: {
        files: {
          'dist/css/main.css': 'src/assets/styles/main.scss',
        },
      },
    },
    watch: {
      js: {
        files: ['src/assets/scripts/*.js'],
        tasks: ['babel'],
      },
      css: {
        files: ['src/assets/styles/*.scss'],
        tasks: ['sass'],
      }
    }
  });

  loadGruntTasks(grunt);

  grunt.registerTask('default', ['sass', 'babel']);
  grunt.registerTask('watch');
}
